package com.tqz.rc.client.controller;

import com.tqz.rc.client.naming.NamingService;
import com.tqz.rc.common.exception.RcException;
import com.tqz.rc.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>客户端注册实例的接口，仅供测试使用。
 *
 * @author tianqingzhao
 * @since 2021/8/30 11:38
 */
@RestController
@RequestMapping("register")
public class RegisterController {

    @Autowired
    private NamingService namingService;

    @PostMapping
    public Result register(String namespaceId,
                           String serviceName,
                           String groupName,
                           String clusterName,
                           String ip,
                           int port) throws RcException {
        namingService.registerInstance(namespaceId, serviceName, clusterName, groupName, ip, port);
        return new Result();
    }
}
